package com.yan.demo.array;
// 删除数据
public class ArrayDemo4 {
    // 平移
    public static void main1(String[] args) {
        int[] arr = {5, 12, 90, 18, 77, 76, 45, 28, 59, 72};
        int index = 2;
        for (int i = index + 1; i < arr.length; i++) {
            arr[i - 1] = arr[i];
        }
        arr[arr.length - 1] = 0;
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
    // 创建新数组法
    public static void main(String[] args) {
        int[] arr = {5, 12, 90, 18, 77, 76, 45, 28, 59, 72};
        int[] arr1 = new int[10];
        int index = 2;
        for (int i = 0; i < arr.length; i++) {
            if(i > index){
                arr1[i - 1] = arr[i];
            } else {
                arr1[i] = arr[i];
            }
        }
        //arr1[arr1.length-1] = 0;
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i] + " ");
        }
    }
}
